package com.wang.experiment.experiment3.booksystem;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

/**
 * @author wr
 * @date 2021/10/20 9:34
 */
@Data
public class Book implements Serializable {
    //唯一uuid
    private String id;
    private String name;
    private String author;
    private String publisher;
    private String isbn;
    private String publicationDate;
    private Integer pages;
    private String summary;

    public Book(String name, String author, String publisher, String isbn, String publicationDate, Integer pages, String summary) {
        this.name = name;
        this.author = author;
        this.publisher = publisher;
        this.isbn = isbn;
        this.publicationDate = publicationDate;
        this.pages = pages;
        this.summary = summary;
        //自动生成id
        this.id = UUID.randomUUID().toString().replace("-", "").substring(0, 8);
    }

    //用于避免id冲突
    public void changeId() {
        this.id = UUID.randomUUID().toString().replace("-", "").substring(0, 8);
    }
}
